home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boosters.arc / UPPER.ASM < prev    next >
Assembly Source File  |  1985-11-09  |  896b  |  45 lines

  1. ;******************************************
  2. ;
  3. ;       Function Upper ( S : AnyString)
  4. ;                             : AnyString;
  5. ;
  6. ;       Converts alphabetics to uppercase.
  7. ;******************************************
  8. UPPER    proc    near
  9.     push    bp
  10.     mov    bp,sp
  11.     push    ds
  12. ;
  13. ;***  Fetch S and check for null length
  14. ;
  15.     mov    cl,[bp+4]    ; length of S
  16.     xor    ch,ch
  17.     lea    si,[bp+5]    ; 1st source byte
  18.     lea    di,[bp+260]    ; length of RESULT
  19.     mov    ss:[di],cl    ; set length
  20.     cmp    cl,0        ; check for null
  21.     jbe    stop
  22. ;
  23. ;***  Set up pointers to S and Result string
  24. ;
  25.     inc    di
  26.     mov    ax,ss
  27.     mov    ds,ax
  28.     mov    es,ax
  29.     cld            ; set direct fwd
  30. u001:    mov    al,[si]
  31.     cmp    al,97        ; 'a'?. . .
  32.     jb    u002        ; below
  33.     cmp    al,122        ; 'z'?. . .
  34.     ja    u002        ; above
  35.     sub    al,32        ; UPPER-CASE IT
  36. u002:    stosb            ; store in result
  37.     inc    si
  38.     loop    u001        ; loop till cx=0
  39. ;
  40. STOP:    pop    ds
  41.     mov    sp,bp
  42.     pop    bp
  43.     ret    256
  44. UPPER    endp
  45.